// pages/homeArticle/homeArticle.js

import {
  reqHomeArticleAll
} from '../../api/homeArticle';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    channelId: 409,
    // 分页
    pageNo: 1,
    // 获取的数据
    pageSize: 8,
    // 总数据
    dataList: []
  },


  onLoad(options) {
    this.getData()
  },

  async getData() {
    let {
      channelId,
      pageNo,
      pageSize
    } = this.data;
    let res = await reqHomeArticleAll({
      channelId,
      pageNo,
      pageSize
    });
    // console.log(res);
    if (res.code == 1) {
      this.setData({
        dataList: [...this.data.dataList, ...res.data.list]
      })
    }
  },
  goBack() {
    wx.navigateBack({})
  },
  toDetail(e) {
		let id = e.currentTarget.dataset.id;
		
    wx.navigateTo({
      url: `/pages/homeArtDetail/homeArtDetail?id=${id}`,
    })
  },
  onReachBottom() {
    this.setData({
      pageNo: this.data.pageNo + 1
    })
    this.getData()
  },

})